#include "CTween.h"

Int32 CALLBACKTYPE GetQuarticValue(
    /* [in] */ Int32 fromValue,
    /* [in] */ Int32 toValue,
    /* [in] */ Millisecond32 elaspedTime,
    /* [in] */ Millisecond32 durationTime,
    /* [in] */ EaseType easeType)
{
    double dx = (double)(toValue - fromValue);
    double delta = 0;
    double r = ((double)elaspedTime) / durationTime;

    switch (easeType) {
    case EaseType_In:
        delta = dx * r * r * r * r;
        break;

    case EaseType_Out:
        r -= 1.0;
        delta = dx * (1 - r * r * r * r);
        break;

    case EaseType_InOut:
        r *= 2.0;
        if (r < 1.0) {
            delta = dx * 0.5 * r * r * r * r;
        }
        else {
            r -= 2;
            delta = dx * 0.5 * (2 - r * r * r * r);
        }

        break;

    default:
        assert(0);
    }

    return fromValue + (Int32)(delta);
}
